/**
 * 
 */
package com.joysw.ui;

import com.joysw.R;

import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.Animation.AnimationListener;


/**   
 * @Title: WelcomeActivity.java 
 * @Package com.joysw.ui 
 * @Description: 欢迎页面
 * @author LIMINGYAN  
 * @date 2015年3月28日 上午7:35:57 
 * @version V1.0   
 */
public class WelcomeActivity extends BaseActivity{
	@Override
	protected void onCreate(Bundle arg0) {
		// TODO Auto-generated method stub
		super.onCreate(arg0);
		final View view = View.inflate(this, R.layout.activity_welcome, null);
		setContentView(view);
		
		AnimationSet animationSet = new AnimationSet(true);
		// 从完全透明到完全不透明
		AlphaAnimation alphaAnimation = new AlphaAnimation(0, 1);
		alphaAnimation.setDuration(1444);
		alphaAnimation.setAnimationListener(new WelcomeAnimationListener());
		animationSet.addAnimation(alphaAnimation);
		// 执行animationSet里面的所有动画效果
		view.startAnimation(animationSet);
	}
	
	private class WelcomeAnimationListener implements AnimationListener {

		@Override
		public void onAnimationEnd(Animation animation) {
			// TODO Auto-generated method stub
			if (true) {// 判断用户是否已登录
				WelcomeActivity.this.startActivity(new Intent(WelcomeActivity.this, LoginActivity.class));
			}
			
			WelcomeActivity.this.finish();
		}

		@Override
		public void onAnimationRepeat(Animation animation) {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void onAnimationStart(Animation animation) {
			// TODO Auto-generated method stub
			
		}
	}
	
	/* 物理返回键无效 */
	@Override
	public boolean onKeyDown(int KeyCode, KeyEvent event) {
		return false;
	}
}
